package com.xxx.encap;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/12 15:01
 * @Copyright 博为峰
 */
public class Person {

    /*
      权限修饰符：public
                private

     */

    //私有化是封装的一种体现
    public String name;
    //private 私有的
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(this.name + "," + this.age + ",吃饭");
    }

    public void setAge(int age) {
        if (age < 0) {
            System.out.println("请设置有效数据");
        } else {
            this.age = age;
        }
    }

    public int getAge(){
        return this.age;
    }


}
